//
//  SHVisitorViewController.swift
//  SHWeibo
//
//  Created by jingming wang on 16/7/19.
//  Copyright © 2016年 cpy.name. All rights reserved.
//

import UIKit

class SHVisitorViewController: UIViewController {
    
    //MARK: - 懒加载
    lazy var tableView:UITableView = UITableView()
    
    //判断用户是否登录
    var isLogin: Bool = SHUserAccountViewModel.sharedTools.isLogin
//    var isLogin: Bool = false
    //访客视图
    var visitorView: SHVisitorView?
    
    override func loadView() {
        
        isLogin ? (view = tableView) : setupVisitorView()
    }

    override func viewDidLoad() {
        super.viewDidLoad()

        
    }
    
    //MARK: - 设置访客视图
    func setupVisitorView() {
        
        visitorView = SHVisitorView()
        visitorView?.closure = {[weak self] in
            self?.didClickLogin()
        }
        view = visitorView
        
        setupNav()
    }
    
    // MARK: - 设置导航按钮
    func setupNav(){
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "登录", target: self, action: "didClickLogin")
        navigationItem.rightBarButtonItem = SHBarButtonItem(title: "注册", target: self, action: "didClickLogin")
        
    }
    
    // MARK: - 监听事件
    @objc private func didClickLogin(){
        let oauthVc = SHOAuthViewController()
        
        presentViewController(UINavigationController(rootViewController: oauthVc), animated: true, completion: nil)
    }
    
}
